<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IFE task 13</title>
</head>
<body>

<lable>请输入北京今天空气质量：<input id="aqi-input" type="text"></lable>
<button id="button">确认填写</button>

<div>您输入的值是:<span id="aqi-display">尚无录入</span></div>

<script>


    (function(){
        var ipt=document.getElementById("aqi-input"),
                btn=document.getElementById("button"),
                text=document.getElementById("aqi-display");

        function listener(){
            var str=ipt.value;
            if(str==null || /^ *$/.test(str))
                text.innerHTML="尚无录入";
            else
                text.innerHTML=ipt.value;
        }


        if(btn.addEventListener) {
            btn.addEventListener('click',listener,false);
        }
        else if(btn.attachEvent) {
            btn.attachEvent('onclick',listener);
        }
        else {
            btn.onclick=listener;
        }
    })();
</script>
</body>
</html>